Skip to content

fix: handle empty responses in HttpHandler#5

Closed
RickieeeDev wants to merge 4 commits into
mainfrom
fix/empty-return-fix
Closed

fix: handle empty responses in HttpHandler#5
RickieeeDev wants to merge 4 commits into
mainfrom
fix/empty-return-fix

Conversation

@RickieeeDev

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the SDK’s HttpHandler response parsing to avoid throwing when the server returns an empty body (common for 204/205 responses), improving resilience for endpoints that legitimately return no content.

Changes:

  • Added explicit handling for empty HTTP responses (204/205, content-length: 0, empty/whitespace body).
  • Switched JSON parsing flow to read the response body as text first, then parse only when non-empty.
  • Centralized “empty response” behavior via a helper method.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/http.ts Outdated
Comment thread src/core/http.ts Outdated

@IamKirbki IamKirbki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so many different checks

Comment thread src/core/http.ts Outdated
Comment thread src/core/http.ts Outdated
Comment thread src/core/http.ts Outdated
@jeroenrinzema

Copy link
Copy Markdown
Contributor

Superseded by #8. The old HttpHandler (http.ts) was replaced by transport.ts, whose unwrap() returns undefined for empty/no-content (204) responses — so the empty-response case is handled centrally now. Thanks @RickieeeDev — closing in favor of #8.

@jeroenrinzema jeroenrinzema deleted the fix/empty-return-fix branch June 25, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants